<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function nearestSq(n){
        return Math.pow(Math.round(Math.sqrt(n)), 2);
    }
</script>
</body>
</html>